<%@page import="java.text.SimpleDateFormat"%>
<%@page import="org.hr.xtime.absence.DayType"%>
<%@ page import="org.hr.xtime.absence.Request" %>
<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'request.label', default: 'Request')}" />
		<title><g:message code="default.create.label" args="[entityName]" /></title>
		<script type="text/javascript">
        $(document).ready(function()
        {
          $("#fromDate").datepicker({dateFormat: 'dd-mm-yy'});
          $("#toDate").datepicker({dateFormat: 'dd-mm-yy'});
        })
    </script>
	</head>
	<body>
		<a href="#create-request" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
		<div class="nav" role="navigation">
			<ul>
				<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
				<li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
			</ul>
		</div>

		<div id="create-request" class="content scaffold-create" role="main">
			<h1><g:message code="default.create.label" args="[entityName]" /></h1>
			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<g:hasErrors bean="${requestInstance}">
			<ul class="errors" role="alert">
				<g:eachError bean="${requestInstance}" var="error">
				<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
				</g:eachError>
			</ul>
			</g:hasErrors>
			<g:form action="saveCreation" >
			
			<fieldset class="box">
				<div class="fieldcontain  ">
					<label for="fromDate">
						Date from
					</label>
					<input name="fromDate" id="fromDate" value="${fromDate?.format('dd-MM-yyyy')}" />
				</div>
				<div class="fieldcontain  ">
					<label for="toDate">
						Date to
					</label>
					<input name="toDate" id="toDate" value="${toDate?.format('dd-MM-yyyy')}" />
				</div>
				<div class="fieldcontain  ">
					<label for="dayType">
						Type of absence
					</label>
					<g:select name="dayType" from="${DayType.list() }" id="dayType"/>
				</div>
				</fieldset>
				<fieldset class="buttons">
					<g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
				</fieldset>
			</g:form>
		</div>
	</body>
</html>
